#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    int x;
    string dw1;
    string dw2;
    string no;
    cin >> x >> dw1 >> no >> no >> dw2;
    int y = 1;
    if (dw1[0] == 'k')
      y = x * 1000000;
    if (dw1.size() == 1)
      y = x * 1000;
    if (dw2.size() == 1)
      y = y / 1000;
    cout << x << " " << dw1 
    << " = " << y << " " << dw2;
    cout <<endl;
  }

  return 0;
}